<?php

namespace App\HttpController\Api\Admin;

use App\Service\Admin\RoleService;

/**
 * 系统角色管理-控制器
 * @author LZH
 * @since: 2021/08/12
 * Class Role
 * @property RoleService $service
 */
class Role extends AdminBase
{
    /**
     * 初始化方法
     * @author LZH
     * @since: 2021/08/12
     */
    protected function init(): void
    {
        $this->service = new RoleService();
    }

    /**
     * 获取角色列表
     */
    public function getRoleList()
    {
        $result = $this->service->getRoleList();
        if (!empty($result)) {
            return $this->respondQuery($result);
        } else {
            return $this->failServerError();
        }
    }

    /**
     * 获取权限列表
     */
    public function getPermissionList()
    {
        $result = $this->service->getPermissionList();
        if (!empty($result)) {
            return $this->respondQuery($result);
        } else {
            return $this->failServerError();
        }
    }

    /**
     * 保存权限
     */
    public function savePermission()
    {
        $result = $this->service->savePermission();
        if (!empty($result)) {
            return $this->respondQuery($result);
        } else {
            return $this->failServerError();
        }
    }
}
